/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Test;

import FarmacieDAL.Medicament;
import FarmacieDAL.SubstantaActiva;
import FarmacieDALManagers.MedicamentManager;
import FarmacieDALManagers.SubstantaActivaManager;
import java.math.BigInteger;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Sri hari
 */
public class TestJPA {

    private MedicamentManager medManager;
    private SubstantaActivaManager subManager;
    private EntityManager em;
    private EntityManagerFactory emf;

    protected void setUp() throws Exception {
        emf = Persistence.createEntityManagerFactory("FarmacieDALPU");
        em = emf.createEntityManager();
        medManager = new MedicamentManager(emf);
        subManager = new SubstantaActivaManager(emf);
    }

    protected void close() throws Exception {
        medManager.close();
        em.close();
        emf.close();
    }

    public void test() {
        SubstantaActiva sub = subManager.searchById(1);
    }

    public static void main(String args[]) {
        System.out.println("Inside TestJPA main");
        TestJPA testJPA = new TestJPA();
        try {
            testJPA.setUp();
            testJPA.test();
            testJPA.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("End of TestJPA main");
    }
}     
